﻿///***************************************************************
/// 시  스  템 : Updms.Crd
/// 단위시스템 : CRD
/// 계      층 : Presentation Layer
/// 프로그램명 : Crd2018r
/// 파  일  명 : Crd2018r.aspx.cs
/// 설      명 : 연간사용분석표
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-12-11 송시명   최초 작성
///***************************************************************
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;

using SMFramework.Adapter;
using SMFramework.Configuration;
using SMFramework.Data;
using SMFramework.Utility;
using SMFramework.Security;
using SMFramework.Web.UI.WebControls.SMGridView;

using Base.AppFramework.Web.UI.CommandBar;
using Base.Dac;

using Updms.Common.BaseClass;
using Updms.Crd.Exe;


namespace Updms.Crd
{
	public partial class Crd2018r : Updms.Common.BaseClass.PageBase
	{
		#region 전역영역

		//프로그램상수
		public static readonly string PID = "Crd2018r";
		public static readonly string gs_path_info = "/updms/Crd/" + PID + ".aspx";

		Global global = new Global();
		Crypto crypto = new Crypto();

		CommCode.Crd crd = new CommCode.Crd(LANG_SET);

		//검색
		protected string kw1 = "";	// 카드
		protected string kw2 = "";	// 기준년도
		protected string gs_card_nm = "";	//카드명(월간사용분석표 띄울때)

		//메뉴 선택값
		protected string gs_sm = "";	

		#endregion

		#region Page_Load, OnPageLoad

		protected void Page_Load(object sender, EventArgs e)
		{
			SetInit();
			if (!Page.IsPostBack)
			{
				// 최초 화면 로딩시 처리해야 할 부분
				OnPageLoad();
				SearchProcess();
			}
		}

		// OnPageLoad
		private void OnPageLoad()
		{
			SetLiterals(global.GetLabelInfoByPgmId(PID, LANG_SET));
			SetBaseYear();
			SetCardInfo(ddl_search_base_year.SelectedValue);
			SetSearchDiv();
		}

		#endregion

		#region InitializeComponent

		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.PreRender += new System.EventHandler(this.Page_PreRender);
		}

		#endregion				

		#region SetInit, SetSearchParameter

		//초기값설정
		private void SetInit()
		{
			gs_sm = (Request.QueryString["sm"] == null || Request.QueryString["sm"].Trim().Length != 7)
					? global.GetDirDepth(PID) : Request.QueryString["sm"].ToString();
		}

		//검색파라미터
		private void SetSearchParameter()
		{
			kw1 = WebControlUtil.GetCheckBoxListValue(cbl_search_card_cd);
			kw2 = ddl_search_base_year.SelectedValue;
			gs_card_nm = WebControlUtil.GetCheckBoxListText(cbl_search_card_cd);
		}

		#endregion

		#region 마스터 Method (SetBaseYear, SetCardInfo)

		//기준년도 설정
		private void SetBaseYear()
		{
			ddl_search_base_year.Items.Clear();

			int li_f_year = Convert.ToInt32(SEARCH_Y_MIN);
			for (int i = li_f_year; i <= Convert.ToInt32(DateUtil.GetYearEx(1, "yyyy")); i++)
			{
				string ls_year = i.ToString();
				ddl_search_base_year.Items.Add(new ListItem(ls_year, ls_year));
			}

			ddl_search_base_year.SelectedValue = DateUtil.GetYearEx(0, "yyyy"); // 기본값은 현재년도
		}

		//카드정보
		private void SetCardInfo(string ls_base_year)
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			lo_dp.AddProperty("ls_base_year", typeof(string), ls_base_year);
			
			using (Crd1010m_NT _Crd1010m_NT = new Crd1010m_NT())
			{
				lo_ds.Merge(_Crd1010m_NT.GetCardInfoListByYearly(lo_dp));
			}		

			cbl_search_card_cd.Items.Clear();
			cbl_search_card_cd.DataSource = lo_ds;
			cbl_search_card_cd.DataMember = "UPDMS_CRD_INFO";
			cbl_search_card_cd.DataTextField = "Card_Nm";
			cbl_search_card_cd.DataValueField = "Card_Cd";
			cbl_search_card_cd.DataBind();

			if (cbl_search_card_cd.Items.Count > 0)
			{
				for (int i = 0; i < cbl_search_card_cd.Items.Count; i++)
				{
					cbl_search_card_cd.Items[i].Selected = true;
				}
			}
		}

		//조회방법
		private void SetSearchDiv()
		{
			crd.SetSearchDiv(rbl_search_div);
		}	

		#endregion

		#region 마스터 Method (기준년도변경, 전년, 당년, 차년)

		//기준년도변경
		protected void ddl_search_base_year_SelectedIndexChanged(object sender, EventArgs e)
		{
			SetCardInfo(ddl_search_base_year.SelectedValue);
		}

		//전년, 차년버튼 누르면
		private void SetPrevNextYear(int pi_year_cnt)
		{
			string ls_year = ddl_search_base_year.SelectedValue;
			string ls_calc_year = Convert.ToString(Convert.ToInt32(ls_year) + pi_year_cnt);

			if (WebControlUtil.CheckDdlValue(ddl_search_base_year, ls_calc_year))
			{
				ddl_search_base_year.SelectedValue = ls_calc_year;
			}

			//버튼처리
			SetEnabledYearBtn();
		}

		//당년설정
		private void SetThisYear()
		{
			string ls_this_year = DateUtil.GetNow("yyyy");
			ddl_search_base_year.SelectedValue = ls_this_year;
			SetEnabledYearBtn();
		}

		//전년, 차년버튼 처리
		private void SetEnabledYearBtn()
		{
			ibtn_prev_year.Enabled = (ddl_search_base_year.SelectedIndex == 0) ? false : true;
			ibtn_next_year.Enabled = (ddl_search_base_year.SelectedIndex == ddl_search_base_year.Items.Count - 1) ? false : true;
			SetCardInfo(ddl_search_base_year.SelectedValue);
		}

		#endregion

		#region 디테일 Method (SetChartByAccount, CreateFileReal, GetLastPaymentDtBtCardCd)

		//계정별 라인챠트
		private void SetChartByAccount(GridView gv, int first_month_idx, int row_idx, bool isGridView1)
		{
			//시리즈
			chart_line.Data.Series = 1;
			string series = String.Empty;

			if (isGridView1)
			{
				series = ConversionUtil.ExtractStrBtwnChar(gv.Rows[row_idx].Cells[2].Text, ";\">", "</a>");
			}
			else
			{
				series = gv.Rows[row_idx].Cells[1].Text + " - " + ConversionUtil.ExtractStrBtwnChar(gv.Rows[row_idx].Cells[2].Text, ";\">", "</a>");
			}

			chart_line.Series[0].Text = series;

			//초기화
			chart_line.Data.Clear();

			double ld_avg = 0.0; //평균
			int li_sum = 0; //합계
			int li_cnt = 0; //금액이 0이상인 월의 수

			for (int i = 0; i < 12; i++)
			{
				int value = Convert.ToInt32(ConversionUtil.RemoveComma(ConversionUtil.ExtractStrBtwnChar(gv.Rows[row_idx].Cells[i + first_month_idx].Text, ");\">", "</span>")));
				li_sum = li_sum + value;

				//수동으로 데이터 바인딩
				chart_line.Data[0, i] = value;

				//X축 라벨링
				string ls_base_dt = "'" + ddl_search_base_year.SelectedValue.Substring(2, 2) + "." + DateUtil.ConvertMonthFormat((i + 1).ToString());
				chart_line.AxisX.Labels[i] = ls_base_dt;

				//0이상일때만 보여준다.
				if (chart_line.Data[0, i] > 0)
				{
					chart_line.Points[0, i].PointLabels.Visible = true;
					li_cnt++;
				}
				else
				{
					chart_line.Points[0, i].PointLabels.Visible = false;
				}
			}

			if (li_cnt > 0)
			{
				ld_avg = li_sum / li_cnt;
			}

			//CustomGridLine 초기화
			chart_line.AxisY.CustomGridLines.Clear();

			//CustomGridLine
			ChartFX.WebForms.CustomGridLine cgl1 = new ChartFX.WebForms.CustomGridLine();
			cgl1.Value = ld_avg;
			cgl1.Color = System.Drawing.Color.Red;
			cgl1.Width = 2;
			cgl1.Text = "Avg. : " + ld_avg.ToString("#,###.##");
			cgl1.Alignment = StringAlignment.Far;
			cgl1.LineAlignment = StringAlignment.Near;
			cgl1.TextColor = Color.Black;

			chart_line.AxisY.CustomGridLines.Add(cgl1);

			mpe_chart_line.Show();
		}

		//실제파일생성
		private void CreateFileReal(string ls_file_nm, DataSet ds)
		{
			try
			{
				string tableName = "UPDMS_CRD_REPORT";
				string ls_stream = FILE_PATH_FTP_UPLOAD + "\\" + ls_file_nm;
				FileInfo file = new FileInfo(ls_stream);

				StreamWriter sw = file.CreateText();

				sw.WriteLine(CommUtil.GetDefaultHtmlTag(PID, global.GetMenuTitle(PID, LANG_SET) + "(" + ddl_search_base_year.SelectedValue + ")" ));
				sw.WriteLine("<table class=\"report\">");
				sw.WriteLine("<tr>");
				sw.WriteLine("<th>계정</th>");
				sw.WriteLine("<th>1월</th>");
				sw.WriteLine("<th>2월</th>");
				sw.WriteLine("<th>3월</th>");
				sw.WriteLine("<th>4월</th>");
				sw.WriteLine("<th>5월</th>");
				sw.WriteLine("<th>6월</th>");
				sw.WriteLine("<th>7월</th>");
				sw.WriteLine("<th>8월</th>");
				sw.WriteLine("<th>9월</th>");
				sw.WriteLine("<th>10월</th>");
				sw.WriteLine("<th>11월</th>");
				sw.WriteLine("<th>12월</th>");
				sw.WriteLine("<th>총액</th>");
				sw.WriteLine("</tr>");
				for (int i = 0; i < DataSetUtil.GetRowCount(ds, tableName); i++)
				{
					string accountNm = DataSetUtil.GetFldStr(ds, tableName, i, "Account_Nm");
					int m01 = DataSetUtil.GetFldInt(ds, tableName, i, "M01");
					int m02 = DataSetUtil.GetFldInt(ds, tableName, i, "M02");
					int m03 = DataSetUtil.GetFldInt(ds, tableName, i, "M03");
					int m04 = DataSetUtil.GetFldInt(ds, tableName, i, "M04");
					int m05 = DataSetUtil.GetFldInt(ds, tableName, i, "M05");
					int m06 = DataSetUtil.GetFldInt(ds, tableName, i, "M06");
					int m07 = DataSetUtil.GetFldInt(ds, tableName, i, "M07");
					int m08 = DataSetUtil.GetFldInt(ds, tableName, i, "M08");
					int m09 = DataSetUtil.GetFldInt(ds, tableName, i, "M09");
					int m10 = DataSetUtil.GetFldInt(ds, tableName, i, "M10");
					int m11 = DataSetUtil.GetFldInt(ds, tableName, i, "M11");
					int m12 = DataSetUtil.GetFldInt(ds, tableName, i, "M12");
					int totalAmt = DataSetUtil.GetFldInt(ds, tableName, i, "Total_Amt");

					//총계
					if (i < DataSetUtil.GetRowCount(ds, tableName) - 1)
					{
						sw.WriteLine("<tr>");
					}
					else
					{
						sw.WriteLine("<tr class=\"total\">");
					}
					sw.WriteLine("<td class=\"lbl\">" + accountNm + "</td>");
					sw.WriteLine("<td class=\"data\">" + m01.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m02.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m03.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m04.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m05.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m06.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m07.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m08.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m09.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m10.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m11.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"data\">" + m12.ToString("#,###,##0") + "</td>");
					sw.WriteLine("<td class=\"total_amt\">" + totalAmt.ToString("#,###,##0") + "</td>");
					sw.WriteLine("</tr>");
				}
				sw.WriteLine("</table>");
				sw.WriteLine("</body>");
				sw.WriteLine("</html>");

				sw.Close();
			}
			catch (Exception e)
			{
				Base.AppFramework.SMEventLog.WriteExceptionLog(e);
				CallMsgBoxInAjax("MSG_ERR_122");	//파일을 생성하지 못했습니다
			}
		}		

		#endregion

		#region 리스트 (SelectYearlyUsingAnalysisList, SelectYearlyUsingAnalysisListByCard, SearchProcess)

		//조회 - 합계치
		private void SelectYearlyUsingAnalysisList()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			//검색
			lo_dp.AddProperty("ls_card_cd", typeof(string), kw1);
			lo_dp.AddProperty("ls_base_year", typeof(string), kw2);
			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

			using (Crd2018r_NT _Crd2018r_NT = new Crd2018r_NT())
			{
				lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisList(lo_dp));
			}

			GridView1.DataSource = lo_ds;
			GridView1.DataBind();
		}

		//조회 - 카드별
		private void SelectYearlyUsingAnalysisListByCard()
		{
			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			//검색
			lo_dp.AddProperty("ls_card_cd", typeof(string), kw1);
			lo_dp.AddProperty("ls_base_year", typeof(string), kw2);
			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

			using (Crd2018r_NT _Crd2018r_NT = new Crd2018r_NT())
			{
				lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisListByCard(lo_dp));
			}

			GridView2.DataSource = lo_ds;
			GridView2.DataBind();
		}		

		//검색
		private void SearchProcess()
		{
			if (WebControlUtil.IsCheckedItems(cbl_search_card_cd))
			{
				SetSearchParameter();
				h_card_cd.Value = kw1;
				h_card_nm.Value = gs_card_nm;

				//일단 모두 숨긴다
				GridView1.Visible = GridView2.Visible = false;

				switch (rbl_search_div.SelectedValue)
				{
					case "AH001":	//합계치
						GridView1.Visible = true;
						SelectYearlyUsingAnalysisList();
						break;
					case "AH002":	//카드별
						GridView2.Visible = true;
						SelectYearlyUsingAnalysisListByCard();
						break;
					default:
						GridView1.Visible = true;
						SelectYearlyUsingAnalysisList();
						break;
				}
			}
			else
			{
				CallMsgBoxInAjax("MSG_ERR_023");	//하나이상의 카드를 선택하세요
			}
		}

		#endregion

		#region Page_PreRender, ChangePageMode

		// Page_PreRender
		private void Page_PreRender(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				using (AccessCheck access = new AccessCheck())
				{
					//접근권한 체크
					if (!access.CheckPgmAccessGrant(PID, USER_ID, ACCESS_LOG_INFO))
					{
						Response.Redirect(URL_NO_AUTHORITY_REDIRECT_BASE);	//사용자의 권한은 요청하신 페이지를 볼 수 없습니다
					}
					//사용권한별 버튼처리
					PagePreRender.SetVisibleCtrl(this, access.CheckPgmUsingGrant(USER_DIV, PID), access.GetVisibleCtrl(PID));
				}
			}
			ChangePageMode();	//헤더에 링크 걸려있음
		}

		// ChangePageMode
		private void ChangePageMode()
		{
			SetGridViewHeader(global.GetColumnListByPgmId(PID, LANG_SET));
		}

		#endregion

		#region GridView이벤트

		//합계치
		protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
		{
			GridView gv = (GridView)sender;			
			string cardCd = WebControlUtil.GetCheckBoxListValue(cbl_search_card_cd);

			int li_curr_month_idx = Convert.ToInt32(DateUtil.GetMonthEx()) + 2;
			string baseYear = ddl_search_base_year.SelectedValue;
			bool isCurrYear = (DateUtil.GetNow("yyyy") == baseYear);
			
			if (e.Row.RowType == DataControlRowType.DataRow)
			{
				//마우스올렸을 때
				e.Row.Attributes.Add("onMouseOver", GRID_ONMOUSEOVER_COLOR);
				e.Row.Attributes.Add("onMouseOut", GRID_ONMOUSEOUT_COLOR);
				
				e.Row.Cells[2].Text
					= "<a href=\"#\" onclick=\"viewChartByAccount('" + e.Row.RowIndex.ToString() + "');\">" + e.Row.Cells[2].Text + "</a>";
				
				for (int i = 3; i <= 14; i++)
				{
					int m = i - 2;	//인덱스를 월로 변경
					string account = gv.DataKeys[e.Row.RowIndex].Values["Account"].ToString();
					bool isTotal = gv.DataKeys[e.Row.RowIndex].Values["View_Order"].ToString() == "BB006";
					string baseYm = baseYear + ((m < 10) ? "-0" + m.ToString() : "-" + m.ToString());	//2011-04
					string data = e.Row.Cells[i].Text;
					string link = (data == "0" || isTotal) ? "javascript:void(0);" : "javascript:viewDetailList('" + cardCd + "','" + account + "','" + baseYm + "');";
					
					string finalData = "<span onclick=\"" + link + "\">" + data + "</span>";
					e.Row.Cells[i].Text = finalData;
				}
					
				switch (gv.DataKeys[e.Row.RowIndex].Values["View_Order"].ToString())
				{
					case "BB006": //총계
						e.Row.Attributes.Add("class", "total_v3");
						for (int i = 0; i < e.Row.Cells.Count; i++)
						{
							e.Row.Cells[i].Attributes.Add("class", "div_line_tb_dbl");
						}
						break;
					default:
						e.Row.Cells[li_curr_month_idx].CssClass = isCurrYear ? "bg_peach" : "";
						break;
				}
			}
		}

		//카드별
		protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
		{
			GridView gv = (GridView)sender;

			int li_curr_month_idx = Convert.ToInt32(DateUtil.GetMonthEx()) + 2;
			string baseYear = ddl_search_base_year.SelectedValue;
			bool isCurrYear = (DateUtil.GetNow("yyyy") == baseYear);

			if (e.Row.RowType == DataControlRowType.DataRow)
			{
				//마우스올렸을 때
				e.Row.Attributes.Add("onMouseOver", GRID_ONMOUSEOVER_COLOR);
				e.Row.Attributes.Add("onMouseOut", GRID_ONMOUSEOUT_COLOR);
				
				e.Row.Cells[2].Text
					= "<a href=\"#\" onclick=\"viewChartByAccount('" + e.Row.RowIndex.ToString() + "');\">" + e.Row.Cells[2].Text + "</a>";

				for (int i = 3; i <= 14; i++)
				{
					int m = i - 2;	//인덱스를 월로 변경
					string account = gv.DataKeys[e.Row.RowIndex].Values["Account"].ToString();
					string cardCd = gv.DataKeys[e.Row.RowIndex].Values["Card_Cd"].ToString();
					
					bool isTotal = false;
					if (gv.DataKeys[e.Row.RowIndex].Values["View_Order"].ToString() == "BA004"
						|| gv.DataKeys[e.Row.RowIndex].Values["View_Order"].ToString() == "BB006")
					{
						isTotal = true;
					}

					string baseYm = baseYear + ((m < 10) ? "-0" + m.ToString() : "-" + m.ToString());	//2011-04
					string data = e.Row.Cells[i].Text;
					string link = (data == "0" || isTotal) ? "javascript:void(0);" : "javascript:viewDetailList('" + cardCd + "','" + account + "','" + baseYm + "');";

					string finalData = "<span onclick=\"" + link + "\">" + data + "</span>";
					e.Row.Cells[i].Text = finalData;
				}
				
				switch (gv.DataKeys[e.Row.RowIndex].Values["View_Order"].ToString())
				{
					case "BA004": //카드별소계
						e.Row.Attributes.Add("class", "total_v1");
						break;
					case "BB006": //총계
						e.Row.Attributes.Add("class", "total_v3");
						for (int i = 0; i < e.Row.Cells.Count; i++)
						{
							e.Row.Cells[i].Attributes.Add("class", "div_line_tb_dbl");
						}
						break;
					default:
						e.Row.Cells[li_curr_month_idx].CssClass = "bg_peach";
						break;
				}
			}

			//머지
			SMGridView sGv = new SMGridView(this.Page, ref GridView2);
			sGv.RowSpanGridView(GridView2, 1);
		}

		#endregion

		#region 버튼이벤트

		//전년
		protected void ibtn_prev_year_Click(object sender, EventArgs e)
		{
			SetPrevNextYear(-1);
			SearchProcess();
		}

		//당년
		protected void ibtn_this_year_Click(object sender, EventArgs e)
		{
			SetThisYear();
			SearchProcess();
		}

		//차년
		protected void ibtn_next_year_Click(object sender, EventArgs e)
		{
			SetPrevNextYear(1);
			SearchProcess();
		}

		//검색
		protected void ibtn_search_Click(object sender, EventArgs e)
		{
			SetEnabledYearBtn();
			SearchProcess();
		}

		//엑셀
		protected void ibtn_excel_Click(object sender, EventArgs e)
		{
			SetSearchParameter();

			DataSet lo_ds = new DataSet();
			DataPack lo_dp = new DataPack();

			lo_dp.AddProperty("ls_card_cd", typeof(string), kw1);
			lo_dp.AddProperty("ls_base_year", typeof(string), kw2);
			lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);			

			using (Crd2018r_NT _Crd2018r_NT = new Crd2018r_NT())
			{
				string excelId = "Excel1";
				string fileName = PID + "(" + global.GetMenuTitle(PID, LANG_SET) + ")";
				
				switch (rbl_search_div.SelectedValue)
				{
					case "AH001":	//카드합계
						lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisList(lo_dp));
						excelId = "Excel1";
						break;
					case "AH002":	//카드별
						lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisListByCard(lo_dp));
						excelId = "Excel2";
						break;
					default:
						lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisList(lo_dp));
						break;
				}
				ExcelUtil.CreateExcelFileX(this.Page, fileName, lo_ds, SetExcelHeaderX(global.GetColumnListByPgmId(PID, LANG_SET), excelId));
			}
		}

		//FTP
		protected void ibtn_ftp_Click(object sender, EventArgs e)
		{
			string fileName = PID + ".html";
			FtpClient fc = new FtpClient(FTP_HOSTNAME, FTP_USERID, crypto.Decrypt(FTP_PASSWORD));

			try
			{
				SetSearchParameter();

				DataSet lo_ds = new DataSet();
				DataPack lo_dp = new DataPack();

				lo_dp.AddProperty("ls_card_cd", typeof(string), kw1);
				lo_dp.AddProperty("ls_base_year", typeof(string), kw2);
				lo_dp.AddProperty("ls_lang_set", typeof(string), LANG_SET);

				using (Crd2018r_NT _Crd2018r_NT = new Crd2018r_NT())
				{
					lo_ds.Merge(_Crd2018r_NT.GetYearlyUsingAnalysisList(lo_dp));
				}
				//파일생성
				CreateFileReal(fileName, lo_ds);

				//FTP전송
				if (FileUtil.IsFileExist(FILE_PATH_FTP_UPLOAD + "\\" + fileName))
				{
					fc.Login();
					fc.BinaryMode = false;

					string[] remoteDir = StringUtil.DelimitedListToStringArray(FTP_DIR_IPHONE_CRD, "/");
					for (int i = 0; i < remoteDir.Length; i++)
					{
						fc.ChangeDir(remoteDir[i]);
					}

					if (fc.IsFileExist(fileName))
					{
						fc.DeleteFile(fileName);
					}
					
					fc.UploadOnlyFile(FILE_PATH_FTP_UPLOAD, fileName, "", "", true);
					fc.Close();
				}
				else
				{
					CallMsgBoxInAjax("MSG_ERR_164");	//전송할 파일이 없습니다.
				}
				CallMsgBoxInAjax("MSG_INF_018");	//전송되었습니다
			}
			catch(Exception ex)
			{
				CallExceptionMsgBoxInAjax(ex);
			}
			finally
			{
				fc.Close();
			}
		}

		//챠트 생성
		protected void lbtn_set_chart_Click(object sender, EventArgs e)
		{
			bool isGridView1 = GridView1.Visible;
			int li_first_month_idx = 3;	//1월의 index값

			SetChartByAccount(isGridView1 ? GridView1 : GridView2, li_first_month_idx, Convert.ToInt32(h_row_idx.Value), isGridView1);
		}

		//카드 체크박스 클릭시
		protected void cbl_search_card_cd_SelectedIndexChanged(object sender, EventArgs e)
		{
			SearchProcess();
		}

		#endregion

	}
}
